package repository

import "virtual-resource-schedule-service/global"

type IClusterRepositoryRepository interface {
	QueryByClusterById(clusterId string) (record VrKubernetsClusterRecord, err error)
}

type ClusterRepository struct {
}

func NewClusterRepository() IClusterRepositoryRepository {
	return &ClusterRepository{}
}

func (repository *ClusterRepository) QueryByClusterById(clusterId string) (
	record VrKubernetsClusterRecord, err error) {
	var results []VrKubernetsClusterRecord
	global.DB.Raw("select * from vr_kuberntes_cluster_record where k8s_cluster_id = ?", clusterId).Scan(&results)
	if len(results) > 0 {
		return results[0], nil
	}
	return
}
